import request from "@/request/model/request.js";
import Method from "@/request/model/method.js";
import {RegisterDTO} from "@/model/account.js";
import {callbackCode, callbackData} from "@/request/model/requestCallback.js";


export const r_a_register = (registerDTO = {...RegisterDTO}) => {
    return request('/api/client/register', Method.POST, null, registerDTO)
        .then(rs => callbackData(rs));
}

export const r_a_login = (loginDTO) => {
    return request('/api/client/login', Method.POST, null, loginDTO)
        .then(rs => callbackData(rs));
}

export const r_a_logout = () => {
    return request('/api/client/logout', Method.GET)
        .then(rs => callbackCode(rs));
}

export const r_a_checkCode = (usernameDTO) => {
    return request('/api/client/checkCode', Method.GET, usernameDTO)
        .then(rs => callbackData(rs));
}

export const r_a_resetPassword = (usernameDTO) => {
    return request('/api/client/resetPassword', Method.GET, usernameDTO)
        .then(rs => callbackData(rs));
}

export const r_a_update = (userUpdateDTO) => {
    return request('/api/client/update', Method.POST, null, userUpdateDTO)
        .then(rs => callbackCode(rs));
}
